#include "fepch.h"
#include "StreamSpawnPoint.h"
#include "FysicsEngine/Application.h"
#include "FysicsEngine/Imgui/EditorUI.h"

namespace Fysics
{
    glm::mat4 StreamSpawnPoint::GetModelMatrix() const
    {
		glm::mat4 model = glm::mat4(1.0f);
		glm::mat4 transform = glm::translate(model, m_Position)
			* glm::scale(model, m_Scale);
		return transform;
    }

	void StreamSpawnPoint::Draw()
	{
		Application& app = Application::Get();
		Renderer::PushObject(this);
		Renderer::Submit(app.GetShader(SHADER_BLUE), app.GetVertexArray(VA_BOX));
	}

	void StreamSpawnPoint::ShowEditPanel()
	{
		EditorUI::Text(GetName());
		static char name[64] = { 0 };
		EditorUI::InputBox("Name", name, 64);
		EditorUI::SetSameLine();
		if (EditorUI::Button("Comfirm", nullptr, 60, 20) && name[0] != '\0')
		{
			SetName(std::string(name));
			name[0] = '\0';
		}

		if (EditorUI::TreeNode("Position"))
		{
			EditorUI::DragFloat("Position x", &m_Position.x, -50.f, 50.f);
			EditorUI::DragFloat("Position y", &m_Position.y, -50.f, 50.f);
			EditorUI::DragFloat("Position z", &m_Position.z, -50.f, 50.f);
			EditorUI::TreePop();
		}		

		if (EditorUI::TreeNode("Scale"))
		{
			EditorUI::SliderFloat("Scale x", &m_Scale.x, 0, 15.f);
			EditorUI::SliderFloat("Scale y", &m_Scale.y, 0, 10.f);
			EditorUI::SliderFloat("Scale z", &m_Scale.z, 0, 15.f);
			EditorUI::TreePop();
		}
		
		if (EditorUI::TreeNode("Fluid attributes"))
		{
			EditorUI::SliderInt("Density", &m_Density, 500, 2000);
			EditorUI::SliderInt("BoundaryDampening", &m_BoundaryDampening, 128, 256);
			EditorUI::TreePop();
		}		
	}
}